package com.eims.sls_app.ui.adapter;

import bls.juejin.cn.R;



import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class GuessNumGvAdapter extends BaseAdapter {
	
	private Context context;
	private int[] pic;
	private String[] title;
	
	

	public GuessNumGvAdapter(Context context, int[] pic, String[] title) {
		super();
		this.context = context;
		this.pic = pic;
		this.title = title;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return pic.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView==null) {
			holder = new ViewHolder();
			LayoutInflater inflact = LayoutInflater.from(context);
			convertView = inflact.inflate(R.layout.item_gv_pictext, null);
			holder.title = (TextView) convertView.findViewById(R.id.tv_title);
			holder.pic = (ImageView)convertView.findViewById(R.id.iv_pic);
			convertView.setTag(holder);
		}else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.pic.setImageResource(pic[position]);
		holder.title.setText(title[position]);
		return convertView;
	}
	
	private class ViewHolder{
		ImageView pic;
		TextView title;
	}

}
